//
//  MBDGroupCommentsTitleCellModel.swift
//  MasterBoy
//
//  Created by kyson on 2024/8/27.
//

import Foundation
import YYText


class MBDGroupCommentsTitleCellModel : MBDCommonCellModel {
    var groupCommentsTitleLayout : YYTextLayout?

    var groupDetail: MBDGroupDetailModel! {
        didSet {
            let groupInfo = String(format: "评论 (%d)", self.groupDetail.groupComments?.count ?? 0)
            let commentsTitleAttributeString = NSMutableAttributedString(string: groupInfo )
            commentsTitleAttributeString.yy_font = UIFont.boldSystemFont(ofSize: 16)
            commentsTitleAttributeString.yy_lineSpacing = 4
            commentsTitleAttributeString.setDynamicTextColor()
            
            let commentsTitleContainer = YYTextContainer()
            
            let commentsTitleWidth = CGRectGetWidth(UIScreen.main.bounds) - MBDGroupDescCellModel.MarginLeftAndRightBackgroundView * 2 - MBDGroupDescCellModel.MarginDescLabelLeftAndRight
            commentsTitleContainer.size = CGSizeMake(commentsTitleWidth , CGFLOAT_MAX)
            let groupDetailLayout = YYTextLayout(container: commentsTitleContainer, text: commentsTitleAttributeString)
            
            self.groupCommentsTitleLayout = groupDetailLayout
        }
    }
    
    override func cellHeight() -> CGFloat {
        return 55
    }
    
}
